// 云函数入口文件
const cloud = require('wx-server-sdk')
const JWT = require('jsonwebtoken')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext =  cloud.getWXContext()
  const token = JWT.sign({
    openid: wxContext.OPENID,
    appid: wxContext.APPID,
    unionid: wxContext.UNIONID,
  }, '6666666')
  return  {
    token: token,
    openid: wxContext.OPENID,
    nickname: '微信用户',
    avator: 'https://robohash.org/123?set=set5'
  }
}